package transactionimplementation

import (
	"reflect"
	"salary/abstracttransactions"
	"salary/database"
	"salary/model"
	"salary/modelimplementation"
)

type ChangeUnaffiliatedTransaction struct {
	abstracttransactions.ChangeAffiliationTransaction
}

func (cut *ChangeUnaffiliatedTransaction) RecordMembership(employee *model.Employee) {
	af := employee.GetAffiliation()
	if reflect.TypeOf(af) == reflect.TypeOf(modelimplementation.UnionAffiliation{}) {
		uaf := af.(*modelimplementation.UnionAffiliation)
		memberId := uaf.GetMemberId()
		database.Database.RemoveUnionMember(memberId)
	}
}

func (cut *ChangeUnaffiliatedTransaction) GetAffiliation() model.Affiliation {
	return &model.NoAffiliation{}
}
